﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Core.Domain;
using Library.Extensions.Expressions;

namespace Core.Queries
{
    public class SettingQuery : Query<Setting>
    {                
        public string Name { get; set; }

        public override Expression<Func<Setting, bool>> ToExpression()
        {
            Expression<Func<Setting, bool>> predicate = x => true;            
            if (!string.IsNullOrWhiteSpace(Name))
                predicate = predicate.And(x => x.Name.StartsWith(Name));

            return predicate;
        }
    }
}
